package Text3;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i <arr.length; i++) {
            arr[i]=scanner.nextInt();
        }
        int dest=-1,cur=0;
        while(cur<=n-1){
            if(arr[cur]!=0){
                dest++;
                swap(arr,dest,cur);
            }
                cur++;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }

    private static void swap(int[] arr, int dest, int cur) {
        int tmp=arr[dest];
        arr[dest]=arr[cur];
        arr[cur]=tmp;
    }

}
